Kernel.module.define('settings', {
	
	title: 'settings',
	file: 'settings.php',
	icon: 'fa-cogs',
	
	init: function() {
		var module = this;

		var crs = (localStorage.getItem("CONFIG_GPS_ROUTE_SERVER") === null) ? "http://localhost:8989/route/":localStorage.getItem("CONFIG_GPS_ROUTE_SERVER");
		var css = (localStorage.getItem("CONFIG_GPS_SOCKET_SERVER") === null) ? "ws://localhost:9000/":localStorage.getItem("CONFIG_GPS_SOCKET_SERVER");
		var cts = (localStorage.getItem("CONFIG_GPS_TILE_SERVER") === null) ? "http://localhost:8080/osm/{z}/{x}/{y}.png":localStorage.getItem("CONFIG_GPS_TILE_SERVER");
		
		$("#routeServerTxt").val(crs);
		$("#socketServerTxt").val(css);
		$("#tileServerTxt").val(cts);

		$(':input').not('[type="checkbox"]').not('[type="reset"]').not('[type="submit"]').on('focus, click', function (e) {
			jsKeyboard.show();
			jsKeyboard.currentElement = $(this);
			jsKeyboard.currentElementCursorPosition = $(this).getCursorPosition();
			console.log('keyboard is now focused on ' + jsKeyboard.currentElement.attr('name') + ' at pos(' + jsKeyboard.currentElementCursorPosition + ')');
		});
		
		$(':input').not('[type="checkbox"]').not('[type="reset"]').not('[type="submit"]').on('focusout', function(e) {
			var rs = $("#routeServerTxt").val();
			var ss = $("#socketServerTxt").val();
			var ts = $("#tileServerTxt").val();
						
			localStorage.setItem("CONFIG_GPS_ROUTE_SERVER", rs)
			localStorage.setItem("CONFIG_GPS_SOCKET_SERVER", ss)
			localStorage.setItem("CONFIG_GPS_TILE_SERVER", ts)
		});
	}
})
